import { request } from 'umi';

/** 获取角色列表 */
export async function getRoleList(params: ROLE.RoleParams, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/roleList', {
    method: 'GET',
    params,
    ...(options || {}),
  });
}

/** 获取所有角色 */
export async function getAllRoleList() {
  return request<Record<string, any>>('/api/allRoleList', {
    method: 'GET',
  });
}
/** 新增角色 */
export async function addRole(data: ROLE.AddRoleParams, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/role', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}
/** 编辑角色 */
export async function editRole(data: ROLE.EditRoleParams, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/role', {
    method: 'PUT',
    data,
    ...(options || {}),
  });
}
/** 删除角色 */
export async function deleteRole(params: ROLE.DeleteRoleParams, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/role', {
    method: 'DELETE',
    params,
    ...(options || {}),
  });
}

/** 获取角色授菜单id数组 */
export async function getRoleAuthInfo(
  params: ROLE.RoleAuthInfoParams,
  options?: Record<string, any>,
) {
  return request<Record<string, any>>('/api/authRole', {
    method: 'GET',
    params,
    ...(options || {}),
  });
}

/** 授权角色 */
export async function authRole(data: ROLE.AuthRoleParams, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/authRole', {
    method: 'POST',
    data,
    ...(options || {}),
  });
}
